/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author The Lunatics
 */
@Entity
@Table(name = "advertisements")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Advertisements.findAll", query = "SELECT a FROM Advertisements a"),
    @NamedQuery(name = "Advertisements.findByAdvertisementId", query = "SELECT a FROM Advertisements a WHERE a.advertisementId = :advertisementId"),
    @NamedQuery(name = "Advertisements.findByType", query = "SELECT a FROM Advertisements a WHERE a.type = :type"),
    @NamedQuery(name = "Advertisements.findByDate", query = "SELECT a FROM Advertisements a WHERE a.date = :date"),
    @NamedQuery(name = "Advertisements.findByCompany", query = "SELECT a FROM Advertisements a WHERE a.company = :company"),
    @NamedQuery(name = "Advertisements.findByItemName", query = "SELECT a FROM Advertisements a WHERE a.itemName = :itemName"),
    @NamedQuery(name = "Advertisements.findByContent", query = "SELECT a FROM Advertisements a WHERE a.content = :content"),
    @NamedQuery(name = "Advertisements.findByUnitPrice", query = "SELECT a FROM Advertisements a WHERE a.unitPrice = :unitPrice"),
    @NamedQuery(name = "Advertisements.findByAvailableUnits", query = "SELECT a FROM Advertisements a WHERE a.availableUnits = :availableUnits")})
public class Advertisements implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "Advertisement_Id")
    private Integer advertisementId;
    @Size(max = 50)
    @Column(name = "Type")
    private String type;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date date;
    @Size(max = 50)
    @Column(name = "Company")
    private String company;
    @Size(max = 50)
    @Column(name = "Item_Name")
    private String itemName;
    @Size(max = 50)
    @Column(name = "Content")
    private String content;
    @Column(name = "Unit_Price")
    private Integer unitPrice;
    @Column(name = "Available_Units")
    private Integer availableUnits;
    @OneToMany(mappedBy = "advertisement")
    private Collection<Purchases> purchasesCollection;
    @JoinColumn(name = "Employee", referencedColumnName = "Employee_Id")
    @ManyToOne
    private Employees employee;

    public Advertisements() {
    }

    public Advertisements(Integer advertisementId) {
        this.advertisementId = advertisementId;
    }

    public Advertisements(Integer advertisementId, Date date) {
        this.advertisementId = advertisementId;
        this.date = date;
    }

    public Integer getAdvertisementId() {
        return advertisementId;
    }

    public void setAdvertisementId(Integer advertisementId) {
        this.advertisementId = advertisementId;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public String getCompany() {
        return company;
    }

    public void setCompany(String company) {
        this.company = company;
    }

    public String getItemName() {
        return itemName;
    }

    public void setItemName(String itemName) {
        this.itemName = itemName;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Integer getUnitPrice() {
        return unitPrice;
    }

    public void setUnitPrice(Integer unitPrice) {
        this.unitPrice = unitPrice;
    }

    public Integer getAvailableUnits() {
        return availableUnits;
    }

    public void setAvailableUnits(Integer availableUnits) {
        this.availableUnits = availableUnits;
    }

    @XmlTransient
    public Collection<Purchases> getPurchasesCollection() {
        return purchasesCollection;
    }

    public void setPurchasesCollection(Collection<Purchases> purchasesCollection) {
        this.purchasesCollection = purchasesCollection;
    }

    public Employees getEmployee() {
        return employee;
    }

    public void setEmployee(Employees employee) {
        this.employee = employee;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (advertisementId != null ? advertisementId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Advertisements)) {
            return false;
        }
        Advertisements other = (Advertisements) object;
        if ((this.advertisementId == null && other.advertisementId != null) || (this.advertisementId != null && !this.advertisementId.equals(other.advertisementId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Advertisements[ advertisementId=" + advertisementId + " ]";
    }
    
}
